<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/error_write.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="lib/sheet.css" type="text/css">
<title>无标题文档</title>
</head>

<body>
<%
If (CStr(Request.form("mm_add")) <> "") Then
	if request.Form("cph")<>"" then cph=request.Form("cph")
	if request.Form("clm")<>"" then clm=request.Form("clm")
	if request.Form("sscd")<>"" then sscd=request.Form("sscd")
	If cph="" Or IsNull(cph) Then error_write "0","请输入车牌号！"
	If sscd="" Or IsNull(sscd) Then error_write "1","请选择所属车队！"
	sql="select * from cl where cph='"&cph&"'"
	set chongfu=server.createobject("adodb.recordset")
	chongfu.open sql,conn,1,1
	if not chongfu.eof then	error_write "2","车牌号重复，请检查！"
	set cmd=Server.CreateObject("ADODB.Command")
	cmd.ActiveConnection = conn
	sql="insert into cl(cph,clm,sscd) values('"&cph&"','"&clm&"',"&sscd&")"
	cmd.CommandText = sql
	cmd.Execute
	cmd.ActiveConnection.Close
	view_url="manage_cl.asp"
	response.Redirect(view_url)

end if
%>

<form name="form1" method="post" action="#">
<table cellspacing="1" cellpadding="2" border="0" bgcolor="black" width="100%">
	<tr bgcolor="silver">
		<th>车牌号</th>
		<th>车辆名</th>
		<th>所属车队</th>
	</tr>
	<tr align="center" bgcolor="#efefef">
		<td><input name="cph" type="text"></td>
		<td><input name="clm" type="text"></td>
		<td>
			<select name="sscd">
		<%
			set cl = Server.CreateObject("ADODB.Recordset")
			sql="select * from cd"
			cl.open sql,conn,1,1
			while not cl.eof
		%>
			<option value="<%=cl("cdid")%>"><%=cl("cdm")%></option>
		<%
				cl.movenext()
			wend
			cl.close
		%>
			</select>
		</td>
	</tr>
	<tr bgcolor="silver">
		<td colspan="3" align="center"><input type="submit" name="Submit" value="提交">&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" name="Reset" value="重置"><input type="hidden" name="mm_add" value="true"></td>
	</tr>
</table>
</form>
<p><a href="javascript:history.go(-1)">&lt;&lt;返回上一页</a></p>
</body>
</html>

